package com.breaker.kata.algorithm;

public class Code02_BSNearLeft {

    public static int mostLeftNoMoreNum(int[] arr, int num) {
        if (arr == null || arr.length == 0) {
            return -1;
        }
        int l = 0;
        int r = arr.length - 1;
        int ans = -1;
        while (l <= r) {
            int mid = (l + r) /2;
            if (arr[mid] >= num) {
                ans = mid;
                r = mid -1;
            }else {
                l = mid + 1;
            }
        }
        return ans;
    }
}
